package com.lottery.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lottery.entity.Prize;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PrizeRepository extends BaseMapper<Prize> {
    
    /**
     * 查找所有可用的奖品（剩余数量大于0）
     */
    @Select("SELECT * FROM prizes WHERE remaining > 0 ORDER BY probability DESC")
    List<Prize> findAvailablePrizes();
    
    /**
     * 查找所有奖品，按概率降序排列
     */
    @Select("SELECT * FROM prizes ORDER BY probability DESC")
    List<Prize> findAllOrderByProbabilityDesc();
}